package PracticeCorrect;

public class PracticeCorrect {
    public static void main(String[] args) {
        Student01[] students = new Student01[20];
        for (int i = 0; i < students.length; i++) {
            Student01 student = new Student01(i+1);
            students[i] = student;
        }
        System.out.println("以下是所有2年级学生信息：");
        for (int i = 0; i < students.length; i++) {
            if (students[i].state == 2) {
                students[i].show();
            }
        }
        System.out.println("=== === ===");
        System.out.println("按成绩排序如下：");
        for (int a = 0; a < 20; a++) {
            boolean swapped = false;
            for (int b = 0; b < 19; b++) {
                if (students[b].score > students[b + 1].score) {
                    Student01 box = students[b + 1];
                    students[b + 1] = students[b];
                    students[b] = box;
                    swapped = true;
                }
            }
            if (swapped = false){
                break;
            }
        }
        for (int i = 0; i < students.length; i++) {
                students[i].show();
        }
    }
}
